package cn.edu.scau.cmi.lishuoxin.client.experiment11;

import Hibernate.cn.edu.scau.cmi.lishuoxin.client.MainApplication;
import Spring.cn.edu.scau.cmi.lishuoxin.client.SpringClient;
import cn.edu.scau.cmi.lishuoxin.client.experiment1.InterfaceMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment2.SingleMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment2.SomeMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment3.AbstractFactoryMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment3.FactoryMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment3.SimpleFactoryMain;
import cn.edu.scau.cmi.lishuoxin.client.experiment4.AdapterClass;
import cn.edu.scau.cmi.lishuoxin.client.experiment4.AdapterObject;
import cn.edu.scau.cmi.lishuoxin.client.experiment5.GroupMain;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Client extends Pane {

	private HBox hbox = new HBox();
	private VBox vbox1 = new VBox();
	private VBox vbox2 = new VBox();
	
	private Image image;
	private ImageView imageView;
	
	private Label label1;
	private Label label2;
	
	private Button button1;
	private Button button2;
	private Button button3;
	private Button button4;
	private Button button5;
	private Button button6;
	private Button button7;
	private Button button8;
	private Button button9;
	private Button button10;
	private Button button11;
	
	public Client() {
		this.addImage();
		this.addLabel();
		this.addButton();
		this.addBox();
	}

	private void addBox() {
		hbox.getChildren().addAll(vbox1,vbox2);
		this.getChildren().add(hbox);
		hbox.setSpacing(20);
	}

	private void addButton() {
		button1 = new Button("实验一:接口编程");
		button1.setOnAction(e->{
			InterfaceMain interfacemain = new InterfaceMain();
			Stage window = new Stage();
			try {
				interfacemain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button2 = new Button("实验二:单例模式");
		button2.setOnAction(e->{
			SingleMain singleMain = new SingleMain();
			Stage window = new Stage();
			try {
				singleMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button3 = new Button("实验二:多例模式");
		button3.setOnAction(e->{
			SomeMain someMain = new SomeMain();
			Stage window = new Stage();
			try {
				someMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button4 = new Button("实验三:简单工厂");
		button4.setOnAction(e->{
			SimpleFactoryMain simpleFactoryMain = new SimpleFactoryMain();
			Stage window = new Stage();
			try {
				simpleFactoryMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button5 = new Button("实验三:工厂模式");
		button5.setOnAction(e->{
			FactoryMain factoryMain = new FactoryMain();
			Stage window = new Stage();
			try {
				factoryMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button6 = new Button("实验三:抽象工厂");
		button6.setOnAction(e->{
			AbstractFactoryMain abstractFactoryMain = new AbstractFactoryMain();
			Stage window = new Stage();
			try {
				abstractFactoryMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button7 = new Button("实验四:适配器(对象)");
		button7.setOnAction(e->{
			AdapterObject adapterObject = new AdapterObject();
			Stage window = new Stage();
			try {
				adapterObject.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button8 = new Button("实验四:适配器(类)");
		button8.setOnAction(e->{
			AdapterClass adapterClass = new AdapterClass();
			Stage window = new Stage();
			try {
				adapterClass.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button9 = new Button("实验五:组合模式");
		button9.setOnAction(e->{
			GroupMain groupMain = new GroupMain();
			Stage window = new Stage();
			try {
				groupMain.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button10 = new Button("实验六:Hibernate框架");
		button10.setOnAction(e->{
			MainApplication mainApplication = new MainApplication();
			Stage window = new Stage();
			try {
				mainApplication.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		button11 = new Button("实验七:Spring框架");
		button11.setOnAction(e->{
			SpringClient springClient = new SpringClient();
			Stage window = new Stage();
			try {
				springClient.start(window);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});
		vbox2.getChildren().addAll(button1,button2,button3,button4,button5,button6,button7,button8,button9,button10,button11);
		vbox2.setSpacing(15);
	}

	private void addLabel() {
		label1 = new Label("学号：   201627010409");
		label2 = new Label("姓名：   李烁新");
		vbox1.getChildren().add(label1);
		vbox1.getChildren().add(label2);
		vbox1.setSpacing(10);
	}

	private void addImage() {
		image = new Image("file:D:\\java_work\\201627010409李烁新\\pic\\1422.jpg");
		imageView = new ImageView();
		imageView.setImage(image);
		vbox1.getChildren().add(imageView);
		imageView.setFitHeight(300);
		imageView.setFitWidth(300);
		imageView.setLayoutX(20);
		imageView.setLayoutY(20);
	}
}
